<template>
  <div id="BondsMaintain">
    <div class="query">
      <!-- --------------- -->
      <div class="homeTitle admin">
        <span>选择债券</span>
        <el-input placeholder="搜索债券代码" v-model="code" class="input-with-select">
          <el-button slot="append" icon="el-icon-search" @click="getdata()"></el-button>
        </el-input>
      </div>
      <div class="queryCon">
        <div class="qSeles">
          <!-- 两个选择 -->
          <div class="xuanze">
            <div v-show="this.$route.query.mode != 2" class="xuanzeCon">
              <span>债券性质：</span>
              <el-select v-model="paramm.nature" placeholder="请选择" size="small">
                <el-option
                  v-for="item in xzoptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
            <div class="xuanzeCon">
              <span>主体评级：</span>
              <el-select v-model="paramm.subject" placeholder="请选择" size="small">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
            <div class="xuanzeCon">
              <span>债项评级：</span>
              <el-select v-model="paramm.debt" placeholder="请选择" size="small">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </div>
          <!-- 按钮 -->
          <div class="btnAb">
            <el-button type="primary" @click="searchParam" size="small">查询</el-button>
          
          </div>
        </div>
      </div>
    </div>
    <!-- 表格 -->
    <div class="table">
      <!-- 表格 -->
      <div class="tablecon">
        <el-table :data="tableData" border style="width: 100%">
          <el-table-column prop="code" label="债券代码" align="center"></el-table-column>
          <el-table-column prop="name" label="债券全称" align="center"></el-table-column>
          <el-table-column prop="simple" label="债券简称" align="center"></el-table-column>
          <el-table-column prop="nature" label="债券性质" align="center"></el-table-column>
          <el-table-column prop="mainUnderwrite" label="主承销商" align="center"></el-table-column>
          <el-table-column prop="mechanismName" label="发行机构名称" align="center"></el-table-column>
          <el-table-column prop="subject" label="主体评级" align="center"></el-table-column>
          <el-table-column prop="debt" label="债项评级" align="center"></el-table-column>
          <el-table-column prop="address" label="操作" align="center" width="172">
            <template slot-scope="scope">
              <el-button size="mini" type="text" @click="selectZhai(scope.row)">选中</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!-- 分页 -->
      <div class="pgfy">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-size="10"
          layout="total, prev, pager, next, jumper"
          :total="totalPage"
        ></el-pagination>
      </div>
      <el-button style="display: block;margin: 0 auto" type="primary" @click="goback">取消</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "BondsMaintain",
  data() {
    return {
      code:'',
      xzoptions:[
          {label: '全部', value: ''},{label: '国债', value: '国债'},
          {label: '地方政府债', value: '地方政府债'},{label: '央行票据', value: '央行票据'},
          {label: '政策性银行债券', value: '政策性银行债券'},{label: '政策性银行次级债', value: '政策性银行次级债'},
          {label: '商业银行债券', value: '商业银行债券'},{label: '商业银行次级债', value: '商业银行次级债'},
          {label: '中期票据', value: '中期票据'},{label: '企业债', value: '企业债'},
          {label: '短期融资券', value: '短期融资券'},{label: '其他金融债', value: '其他金融债'},
          {label: '集合票据', value: '集合票据'},{label: '资产支持证券', value: '资产支持证券'},
          {label: '其他债券', value: '其他债券'},{label: '公司债', value: '公司债'},
          {label: '二级资本工具', value: '二级资本工具'},{label: '非公开定向债务融资工具', value: '非公开定向债务融资工具'},
          {label: '同业存单', value: '同业存单'},{label: '资产管理公司金融债', value: '资产管理公司金融债'},
          {label: '超短期融资券', value: '超短期融资券'},{label: '铁道债', value: '铁道债'},
          {label: '可分离债', value: '可分离债'}
      ],
   options: [
          {label: '全部', value: ''},{label: 'AAA', value: 'AAA'},
          {label: 'AA+', value: 'AA+'},{label: 'AA', value: 'AA'},
          {label: 'AA-', value: 'AA-'},{label: 'A+', value: 'A+'},
          {label: 'A', value: 'A'},{label: 'A-', value: 'A-'},
          {label: 'BBB+', value: 'BBB+'},{label: 'BBB', value: 'BBB'},
          {label: 'BB+', value: 'BB+'},{label: 'BB', value: 'BB'},
          {label: 'BB-', value: 'BB-'},{label: 'B+', value: 'B+'},
          {label: 'B', value: 'B'},{label: 'B-', value: 'B-'},
          {label: 'CCC+', value: 'CCC+'},{label: 'CCC', value: 'CCC'},
          {label: 'CC+', value: 'CC+'},{label: 'CC', value: 'CC'},
          {label: 'CC-', value: 'CC-'},{label: 'C+', value: 'C+'},
          {label: 'C', value: 'C'},{label: 'C-', value: 'C-'},
          
      ],
      
      tableData: [],
      paramm: {},
      // 分页
      totalPage: 0,
      currentPage: 1,
      mode: this.$route.query.mode
    };
  },
  methods: {
    searchParam() {
      this.currentPage = 1
      
       this.getBondList()
    },
    getdata() {
        this.getBondList()
    },
    // 分页
    handleSizeChange(val) {
    },
    goback() {
        this.$router.go(-1)
    },
    // 分页
    handleCurrentChange(val) {
           this.currentPage = val
    },
    selectZhai(row) {
        this.$bus.$emit('boudId', row.id)
        sessionStorage.setItem('bondId', row.id)
        this.$router.go(-1)
        //this.$router.push('accountDetail')
    },
   
    getBondList() {
      let data = {}
      if(this.paramm.nature != '') {
        data.nature = this.paramm.nature
      }
      if(this.paramm.subject != '') {
        data.subject = this.paramm.subject
      }
      if(this.paramm.debt != '') {
        data.debt = this.paramm.debt
      }
      data.code = this.code
      data.page = this.currentPage
      data.bondType = this.mode
      this.axios.get('bond/selectList', {
            params: data
        }).then((res) => {
            this.tableData = res.data.data
            this.totalPage = res.data.pageInfo.total
        })
    }
  },
  watch: {
      currentPage(val){
     
          this.getBondList()
      }
  },
  mounted() {
      this.getBondList()
  }
};
</script>

<style lang="scss">
#BondsMaintain {
  .homeTitle {
    &.admin {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0 20px;
      border-bottom: 1px solid black;
      .el-input {
        width: 300px;
      }
    }
  }
  .queryCon {
    background: white;
    padding: 0 20px 20px;
    .qSeles {
      padding-top: 20px;
      .xuanze {
        display: flex;
        align-items: center;
        margin-bottom: 10px;
        flex-wrap: wrap;
        .xuanzeCon {
          height: 40px;
          display: flex;
          align-items: center;
          margin-right: 30px;
          .el-input {
            width: 200px;
          }
        }
      }
      .btnAb {
        margin-top: 30px;
        .el-button {
          margin-right: 30px;
        }
      }
    }
  }
  .table {
    background: white;
    .tablecon {
      padding: 20px;
    }
    .pgfy {
      padding: 20px;
      padding-top: 10px;
      text-align: right;
    }
  }
}
</style>
